package com.dcy.daily.service.skill;

import com.dcy.daily.common.aspect.TargetDataSource;
import com.dcy.daily.common.constant.Constants;
import com.dcy.daily.core.mapper.AccountMapper;
import com.dcy.daily.core.model.Account;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author duanchunyu
 * @version 1.0.0
 * @createTime 2021年06月01日 14:25:00
 */
@Service
public class AccountService {

    @Autowired
    private AccountMapper accountMapper;

    @TargetDataSource(Constants.DATA_SOURCE_TYPE.PRIMARY)
    public Account getAccount(Integer id){
       return accountMapper.selectByPrimaryKey(id);
    }

    @TargetDataSource(Constants.DATA_SOURCE_TYPE.SECONDARY)
    public int insertAccount(Account account){
        return accountMapper.insert(account);
    }

    //@LogAspect
    public void transfer(){
        System.out.println("A:-1000");
        int z =  3/0;
        System.out.println("B:+1000");
    }

    public void transfer1(){
        System.out.println("A:-2000");
        System.out.println("B:+2000");
    }
}
